<!-- /*
 * @Author: 谢力 843926058@qq.com
 * @Date:   2019-11-06
 * @Last Modified by:   谢力
 * @Last Modified time: 2019-11-07
 */ -->
<template>
    <div class="ui-mode-container ui-mode-box flex-col">
        <div class="ui-header-item gradient">
            <div class="ui-header-arraw prev" @touchstart.stop @click="handleBack">
                <i class="iconfont icon iconjiantou-zuo-cuxiantiao"></i>
            </div>
            <div class="ui-header-title">查看文件</div>
            <div class="ui-header-arraw next flex-row align-center" @touchstart.stop @click="handleHome">
                <i class="iconfont icon iconi-home"></i>
            </div>
        </div>
        <div class="ui-mode-content flex1" ref="scroll">
            <template>
                <div class="mt-user-info">
                    <!-- pdf文件预览 -->
                    <div class="item flex-row align-center" @click="goMiniProgramPage({name:'pdf文件预览',type:'pdf',url:'https://global-application-001.downline.cn/app.downline.cn/vnd/20200729_103539TbWQiB.pdf',jumpType:'h5Url',jumpUrl:'front_page_index.html?v=1.0#/my/miniProgram/file?isFakeJump=true'})">
                        <div class="label flex1">pdf文件预览</div>
                        <span class="value">点击查看</span>
                        <i class="icon iconfont iconjiantou-you-cuxiantiao"></i>
                    </div>
                    <!-- xls文件预览 -->
                    <div class="item flex-row align-center" @click="goMiniProgramPage({name:'xls文件预览',type:'excel',url:'https://global-application-001.downline.cn/app.downline.cn/vnd/20200729_103543y6HFAW.xls',jumpType:'h5Url',jumpUrl:'front_page_index.html?v=1.0#/my/miniProgram/file?isFakeJump=true'})">
                        <div class="label flex1">xls文件预览</div>
                        <span class="value">点击查看</span>
                        <i class="icon iconfont iconjiantou-you-cuxiantiao"></i>
                    </div>
                    <!-- doc文件预览 -->
                    <div class="item flex-row align-center" @click="goMiniProgramPage({name:'doc文件预览',type:'word',url:'https://global-application-001.downline.cn/app.downline.cn/vnd/20200729_103535tSxdw8.doc',jumpType:'h5Url',jumpUrl:'front_page_index.html?v=1.0#/my/miniProgram/file?isFakeJump=true'})">
                        <div class="label flex1">doc文件预览</div>
                        <span class="value">点击查看</span>
                        <i class="icon iconfont iconjiantou-you-cuxiantiao"></i>
                    </div>
                </div>
            </template>
        </div>
    </div>
</template>
<script>
import mixinCommon from '@/views/content/mixins/common';
import mixinRequest from '@/views/content/mixins/request';
export default {
    name: 'my',
    data(){
        return {
            public_agent_info:{},
            public_user_info:{}
        };
    },
    mixins:[
        mixinCommon,
        mixinRequest
    ],
    components:{
    },
    computed:{
    },
    watch:{
        resourceLoaded:{
            handler(flag){
                flag&&this.$nextTick(this.init);
            },
            immediate:true
        }
    },
    created(){
    },
    mounted(){
    },
    methods:{
        /*
         * 初始化
         */
        init(){
            this.getPageInfo({
                name:'my',
                param:{
                    invoke_method:'user_and_shop_info'
                }
            }).then(({result,response})=>{
                this.public_agent_info=result.public_agent_info||{};
                this.public_user_info=result.public_user_info||{};
                this.public_goods_order_record=result.public_goods_order_record||{};
                document.title=this.public_agent_info.application_name;
                this.setState({
                    key:'public_agent_info',
                    value:this.public_agent_info
                });
                this.setState({
                    key:'public_user_info',
                    value:this.public_user_info
                });
            });
        },
        /*
         * 跳转至小程序文件预览界面
         */
        goMiniProgramPage(item){
            if(this.isMiniProgram){
                var link=item.jumpUrl?encodeURIComponent(item.jumpUrl):'';
                var url='/pages/index/check_file'+'?url='+encodeURIComponent(item.url)+'&type='+item.type+'&jumpType='+item.jumpType+'&jumpUrl='+link;
                this.$wx.miniProgram.redirectTo({url});
            }else{
                this.showMessage('调用小程序 跳转页面！');
            };
        },
        handleBack(){
            let protocol = window.location.protocol //协议
            let host = window.location.host //主机
            if(this.$route.query.isFakeJump){
                window.location.href =  protocol + "//" + host + '/weichat_enter_4_app_wholefarm?fake_id=' + this.public_user_info.id_sns + '&empower_code=5678&jump_type=701&new_page=front_page_index.html?v=1.0#/my/miniProgram?isFakeJump=true';
            }else{
                this.$router.go(-1);
            }
        }
    },
    beforeDestroy(){
    }
}
</script>
<style lang="less" scoped>
.mt-user-info{
    border-top:solid 1px #e9e9e9;
    .item{
        position:relative;
        padding:0 0.5rem;
        line-height:3rem;
        font-size:0.8rem;
        border-bottom:solid 1px #e9e9e9;
        .label{
            color:#4a4a4a;
        }
        .value{
            color:#4a4a4a;
            margin-right:0.3rem;
        }
        .icon{
            color:#888;
            font-size:0.8rem;
        }
        &:last-child{
            border-top:none;
        }
        &:active{
            background:#eee;
        }
    }
}
</style>
